package com.fattyCorps.common.packet;

import cn.hutool.extra.spring.SpringUtil;
import com.fattyCorps.common.mgr.Cfg;
import com.fattyCorps.common.obj.config.ItemMould;
import lombok.Data;

@Data
public class Item extends PacketElem {
    private Integer typeId;
    private Integer num;
    private String name;

    public static Item makeItem(Integer itemTypeId, Integer num) {
        ItemMould itemMould = SpringUtil.getBean(Cfg.class).getCfg(ItemMould.class, itemTypeId);
        Item newItem = new Item();
        newItem.setTypeId(itemTypeId);
        newItem.setNum(num);
        newItem.setName(itemMould.getName());

        return newItem;
    }
}
